#ifndef DW_GRAPHICS_RENDERVISITOR_H
# define DW_GRAPHICS_RENDERVISITOR_H

# include "graphics/node.h"

namespace dw {
	namespace graphics {
		
		class VertexBuffer;
		class IndexBuffer;
		class Material;
		class Frustum;

		struct Batch
		{
			Matrix4f xform;
			VertexBuffer* vb;
			IndexBuffer* ib;
			Material* material;
			uint32 primitiveType;
			uint32 indexStart;
			uint32 indexCount;
			uint32 minIndex;
			uint32 maxIndex;
			Colorf color;
		};

		class RenderVisitor : public dw::base::Visitor< Node >
		{
		public:

			Node* _cameraNode;

			Frustum* _frustum;

			unsigned _numNodeTotal;

			unsigned _numNodes;

			float _dt;

		public:

			RenderVisitor();

			bool visit(Node* visited);

			void showHidden(const bool show);

			void render(Renderer* renderer);

		public:

			// sort Batch by material and by distance from camera
			typedef std::multimap<std::string, Batch>	BatchMaterialMap;

			typedef std::multimap<float, Batch>				BatchZMap;

		public:

			BatchMaterialMap _renderBatchesByMaterial;

			BatchMaterialMap _renderBatchesByTransparentMaterial;

			BatchZMap _renderBatchesZSort;

			bool _showHidden;

		};

	} // namespace graphics
} // namespace dw

#endif // !DW_GRAPHICS_RENDERVISITOR_H